private static void CreatePersonalRef(String targetPath, String dirName, String alias, String path) { try { DirectoryInfo di = FsBase.AddDirectory(alias, path); if (di.Exists) { String shortcutLocation = Path.Combine(di.FullName, dirName + ".lnk"); IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell(); IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(shortcutLocation); shortcut.TargetPath = targetPath; shortcut.Save(); } } catch (Exception e) { Console.WriteLine("createPersonalRef: " + e.Message); } }
public static void AddContractDirectory(RequestPackage rqp) { Guid sessionId = rqp.SessionId; Object temp = rqp["auction_uid"]; if (temp != null && temp.GetType() == typeof(Guid)) { Guid auctionUid = (Guid)temp; DataSet ds = Db.Prep.GetDirInf(sessionId, auctionUid); if (ds != null && ds.Tables.Count > 1) { DataTable dt0 = ds.Tables[0]; if (dt0 != null && dt0.Rows.Count > 0 && dt0.Columns.Count > 0) { String auctionNumber = (dt0.Rows[0]["an"] as String) ?? "x"; String sd = (dt0.Rows[0]["sd"] as String) ?? "x"; String sdDate = "x"; if (sd.Length >= 2) { sdDate = sd.Substring(0, 2); } String sdMonth = "x"; if (sd.Length >= 5) { sdMonth = sd.Substring(3, 2); } String sdYear = "x"; if (sd.Length >= 10) { sdYear = sd.Substring(6, 4); } String ed = (dt0.Rows[0]["ed"] as String) ?? "x"; String edDate = "x"; if (ed.Length > 2) { edDate = ed.Substring(0, 2); } String edMonth = "x"; if (ed.Length >= 5) { edMonth = ed.Substring(3, 2); } String userName = (dt0.Rows[0]["un"] as String) ?? "x"; String distrName = (dt0.Rows[0]["dn"] as String) ?? "x"; String alias = "contracts"; String path = String.Format(@"\Заявки\{0:d4}\{1:d2}\{2:d2}.{1:d2}-{4:d2}.{3:d2} {5} {6} {7}", sdYear, sdMonth, sdDate, edMonth, edDate, auctionNumber, userName, distrName); DirectoryInfo di = FsBase.AddDirectory(alias, path); if (di.Exists) { Db.SessionLogWriteLine(sessionId, "HttpDataServerProject8.StoredProcedures.addContractDirectory()", String.Format("Создан каталог: '{0}'", di.FullName)); String firstCustomerName = CreateCustomerDirs(di, ds.Tables[1]); CreateRefFile(di, auctionNumber); DownloadDocFiles(sessionId, di, auctionNumber); alias = "persons"; String custName = firstCustomerName.Substring(0, Math.Min(firstCustomerName.Length, 100)); String dirName = String.Format(@"{0:d2}.{1:d2}-{2:d2}.{3:d2} {4} {5}", sdDate, sdMonth, edDate, edMonth, auctionNumber, custName); switch (userName) { case "Коледова": path = String.Format(@"\Коледова Юлия Ивановна\АУКЦИОНЫ\Заявки\{0:d4}\{1:d2}", sdYear, sdMonth); CreatePersonalRef(di.FullName, dirName, alias, path); break; case "Сущева": path = String.Format(@"\Сущева Ольга Николаевна\АУКЦИОНЫ\Заявки\{0:d4}\{1:d2}", sdYear, sdMonth); CreatePersonalRef(di.FullName, dirName, alias, path); break; case "Шанина": path = String.Format(@"\Шанина Елена Николаевна\АУКЦИОНЫ\Заявки\{0:d4}\{1:d2}", sdYear, sdMonth); CreatePersonalRef(di.FullName, dirName, alias, path); break; case "Углова": path = String.Format(@"\Углова Алёна Александровна\АУКЦИОНЫ\Заявки\{0:d4}\{1:d2}", sdYear, sdMonth); CreatePersonalRef(di.FullName, dirName, alias, path); break; case "Соколов": path = String.Format(@"\Соколов Евгений Анатольевич\АУКЦИОНЫ\Заявки\{0:d4}\{1:d2}", sdYear, sdMonth); CreatePersonalRef(di.FullName, dirName, alias, path); break; case "Магергут": case "Скворцова": case "Лобанова": alias = "mag_dep"; path = String.Format(@"\новые аукционы"); try { String status; // пробуем взять папку в Контрактах String sAalias = "contracts"; String sPath = String.Format(@"\Заявки\{0:d4}\{1:d2}", sdYear, sdMonth); DirectoryInfo di1 = FsBase.GetDirectoryInfo(sAalias, sPath, auctionNumber); if (di1 != null) { // копируем в отдел Магергут status = FsBase.CopyFiles(alias, path, di1); } else { status = String.Format("Ошибка копирования: Папка с аукционом № {0} не найдена.", auctionNumber); } Console.WriteLine(status); } catch (Exception e) { Console.WriteLine(e.Message); } break; case "Завалова": case "Борисова": alias = "zav_dep"; path = String.Format(@"\новые аукционы"); try { String status; // пробуем взять папку в Контрактах String sAalias = "contracts"; String sPath = String.Format(@"\Заявки\{0:d4}\{1:d2}", sdYear, sdMonth); DirectoryInfo di1 = FsBase.GetDirectoryInfo(sAalias, sPath, auctionNumber); if (di1 != null) { // копируем в отдел Заваловой status = FsBase.CopyFiles(alias, path, di1); } else { status = String.Format("Ошибка копирования: Папка с аукционом № {0} не найдена.", auctionNumber); } Console.WriteLine(status); } catch (Exception e) { Console.WriteLine(e.Message); } break; default: break; } } } } } }