Beispiel #1
0
        protected void btnImport_Click(object sender, EventArgs e)
        {
            string sErr = "";

            ImportExport.ImportExportClass ie = new ImportExport.ImportExportClass();
            string sPath = Server.MapPath("~/temp/");

            //get the file from the browser
            if ((fupFile.PostedFile != null) && (fupFile.PostedFile.ContentLength > 0))
            {
                string sFileName = System.IO.Path.GetFileName(fupFile.PostedFile.FileName);
                string sFullPath = sPath + sFileName;
                try
                {
                    fupFile.PostedFile.SaveAs(sFullPath);
                    ////Response.Write("The file has been uploaded.");

                    ////confirm the zip file exists in our temp directory
                    if (File.Exists(sFullPath))
                    {
                        if (!ie.doFileLoad(sPath, sFullPath, sFileName, ui.GetSessionUserID(), ref sErr))
                        {
                            ui.RaiseError(Page, sErr, true, "");
                        }
                        else
                        {
                            //all good

                            Response.Redirect("importReconcile.aspx", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ui.RaiseError(Page, ex.Message, true, "");
                }
            }
            else
            {
                ui.RaiseError(Page, "Please select a file to upload.", true, "");
            }
        }
        protected void btnImport_Click(object sender, EventArgs e)
        {
            string sErr = "";

            ImportExport.ImportExportClass ie = new ImportExport.ImportExportClass();
            string sPath = Server.MapPath("~/temp/");

            //get the file from the browser
            if ((fupFile.PostedFile != null) && (fupFile.PostedFile.ContentLength > 0))
            {
                string sFileName = System.IO.Path.GetFileName(fupFile.PostedFile.FileName);
                string sFullPath = sPath + sFileName;
                try
                {
                    fupFile.PostedFile.SaveAs(sFullPath);
                    ////Response.Write("The file has been uploaded.");

                    ////confirm the zip file exists in our temp directory
                    if (File.Exists(sFullPath))
                        if (!ie.doFileLoad(sPath, sFullPath, sFileName, ui.GetSessionUserID(), ref sErr))
                        {
                            ui.RaiseError(Page, sErr, true, "");
                        }
                        else
                        {
                            //all good

                            Response.Redirect("importReconcile.aspx", false);
                        }
                }
                catch (Exception ex)
                {
                    ui.RaiseError(Page, ex.Message, true, "");
                }
            }
            else
            {
                ui.RaiseError(Page, "Please select a file to upload.", true, "");
            }
        }
        public string wmExportTasks(string sTaskArray)
        {
            acUI.acUI ui = new acUI.acUI();
            ImportExport.ImportExportClass ie = new ImportExport.ImportExportClass();

            string sErr = "";

            //pretty much just call the ImportExport function
            try
            {
                //what are we gonna call the final file?
                string sUserID = ui.GetSessionUserID();
                string sFileName = sUserID + "_backup";
                string sPath = Server.MapPath("~/temp/");

                if (sTaskArray.Length < 36)
                return "";
                sTaskArray = ui.QuoteUp(sTaskArray);

                if (!ie.doBatchTaskExport(sPath, sTaskArray, sFileName, ref sErr))
                {
                    throw new Exception("Unable to export Tasks." + sErr);
                }

                if (sErr == "")
                    return sFileName + ".zip";
                else
                    return sErr;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public string wmUpdateImportRow(string sObjectType, string sID, string sNewCode, string sNewName, string sVersion, string sImportMode)
        {
            //note not all arguments are used for all types, but are required for all

            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            ImportExport.ImportExportClass ie = new ImportExport.ImportExportClass();

            try
            {
                string sUserID = ui.GetSessionUserID();

                if (sID != "")
                {
                    string sErr = "";
                    string sSQL = "";

                    //just to be safe...
                    sObjectType = sObjectType.ToLower();

                    switch (sObjectType)
                    {
                        case "task":
                            switch (sImportMode)
                            {
                                case "New":
                                    sSQL = "update import_task set" +
                                        " task_code = '" + sNewCode.Replace("'", "''") + "'," +
                                        " task_name = '" + sNewName.Replace("'", "''") + "'," +
                                        " version = 1.000," +
                                        " conflict = null," +
                                        " import_mode = '" + sImportMode + "'" +
                                        " where task_id = '" + sID + "'" +
                                        " and user_id = '" + sUserID + "'";
                                    break;
                                case "New Version":
                                    sSQL = "update import_task set" +
                                        " task_code = src_task_code," +
                                        " task_name = src_task_name," +
                                        " version = '" + sVersion + "'," +
                                        " conflict = null," +
                                        " import_mode = '" + sImportMode + "'" +
                                        " where task_id = '" + sID + "'" +
                                        " and user_id = '" + sUserID + "'";
                                    break;
                                //case "Overwrite":
                                //    sSQL = "update import_task set" +
                                //        " task_code = src_task_code," +
                                //        " task_name = src_task_name," +
                                //        " version = src_version," +
                                //        " conflict = null," +
                                //        " import_mode = '" + sImportMode + "'" +
                                //        " where task_id = '" + sID + "'" +
                                //        " and user_id = '" + sUserID + "'";
                                //    break;
                                default:
                                    break;
                            }
                            break;

                        default:
                            break;
                    }

                    if (sSQL != "")
                    {
                        if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                        {
                            throw new Exception("Unable to update.<br />" + sErr);
                        }
                    }
                    else
                        throw new Exception("Update SQL not set.<br />" + sErr);

                    //now, rescan for conflicts.
                    switch (sObjectType)
                    {
                        case "task":
                            if (!ie.IdentifyTaskConflicts(sUserID, sID, ref sErr))
                                throw new Exception("Unable to scan conflicts.<br />" + sErr);

                            break;

                        default:
                            break;
                    }

                    return "";
                }
                else
                {
                    throw new Exception("Unable to update row. Missing required data. (Fields cannot be blank.)");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string wmImportSelected(string sTaskList)
        {
            acUI.acUI ui = new acUI.acUI();
            ImportExport.ImportExportClass ie = new ImportExport.ImportExportClass();

            string sErr = "";

            try
            {
                string sUserID = ui.GetSessionUserID();

                if (!ie.Import(sUserID, sTaskList, ref sErr))
                    throw new Exception("Unable to import Items.<br />" + sErr);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return sErr;
        }